﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GpgCore.Products;

namespace GpgCore.Corporations
{
    public class Warehouse
    {
        public Dictionary<ProductType, Product> Products;

        public Warehouse()
        {
            Products = new Dictionary<ProductType, Product>();
            foreach (var val in Enum.GetValues(typeof(ProductType)))
            {
                var prod = (ProductType) val;
                Products.Add(prod, new Product(prod, 0));
            }
        }

        public double ExtractProduct(double s1Demand, ProductType prodType)
        {
            if (Products[prodType].Count < s1Demand)
                s1Demand = Products[prodType].Count;

            Products[prodType].Count -= s1Demand;
            return s1Demand;
        }

        public double ExtractAllProduct(ProductType prodType)
        {
            var count = Products[prodType].Count;
            Products[prodType].Count = 0;
            return count;
        }
    }
}
